<template> 
        <!-- <div>
            <van-search v-model="value" placeholder="请输入搜索关键词"  @search="findGoods()"></van-search>
        </div> -->
<div class="menu-list">
                        <div v-for="item in list" :key="item.id">
                            <div class="time">
                                <span>2023-2-6</span>
                                <span>交易成功&nbsp;&nbsp;|&nbsp;&nbsp;<van-icon name="delete-o"  @click="deleteGoods(item.id)"/></span>
                            </div>
                            <div  @click="todetail(item.id)">
                                <van-card num="2" :price="item.price" desc="02月10日提货" :title="item.shop"
                                    :thumb="item.picture">
                                </van-card>
                                    <van-button round color="#ED0D5B" plain size="small"
                                        type="danger" @click="buytoo(item)">再次购买</van-button>
                            </div>
                            <hr>
                        </div>
                    </div>
</template>

<script setup lang="ts">
// import {RequestGoodsList} from '@/api/goods'
import {type Ref ,ref,onMounted} from 'vue'
// import type {IGoods} from '@/types/types'
// import {RequestSearchList } from '@/api/search.ts'
import {usePyStore} from '@/stores/pyok'
import { useCartStore } from '@/stores/cart';
import {Toast} from 'vant'
import {useRouter} from 'vue-router'

const router = useRouter()

const usepyok = usePyStore()
const useCart = useCartStore()
// const value = ref('')
const list:Ref<Array<any>> = ref([])

list.value = usepyok.list
// 删除
const deleteGoods =(id:number)=>{
    const index = list.value.findIndex(item=>item.id==id)
    list.value.splice(index,1)  
}
// 再次购买方法
const buytoo = (item:any)=>{
    useCart.saveCart(item)
    Toast('加入购物车成功')
}
// 商品详情
const todetail = (id:number)=>{
    router.push({path:'/detail',query:{id}})
} 
</script>

<style scoped lang="scss">
.menu-list {
    margin-top: 10px;
    width: 100%;
    display: flex;
    justify-content: space-around;
    flex-direction: column;

    .time {
        padding: 5px 24px 5px 24px;
        display: flex;
        justify-content: space-between;
        background-color: #ffffff;

    }

    .time2 {
        padding: 5px 24px 5px 24px;
        display: flex;
        justify-content: space-between;
        background-color: #ffffff;

        .redsapn {
            color: red;
        }
    }
    .van-button{
        float: right;
    }
}
</style>